/*
 * @Date: 2022-03-29 12:39:37
 * @LastEditors: luoqi
 * @LastEditTime: 2022-04-11 20:49:53
 * @FilePath: /payment/pay/src/pages/Tenant/TenantRecharge.jsx
 */
import React, { useForm } from 'react'
import { Form, Input, Button,message,Select } from 'antd';
import Tab from '../../components/Tabs';
import style from './recharge.module.css'
import axios from '../../util/axios'
import qs from 'qs'
const { Option } = Select;
export default function TenantRecharge() {
  const [form] = Form.useForm();

  const onFinish = (values) => {
    console.log(values);
    axios({
      url:'/shouGongChongZhi',
      method:'post',
      data:qs.stringify({
        money:values.num,
        name:JSON.parse(localStorage.getItem('user')).uName,
      }),
      // headers:{
      //   'Content-Type': 'application/json'
      // }
    }).then(res=>{
      console.log(res);
      if(res.code===200){
        message.success('请求成功，待管理员审核');
        // setData(res.data.map(item => ({ ...item, key: item.id })))
        // setPag({ ...pag, total: res.count })
      }
    })  

    onReset()
  };

  const onReset = () => {
    form.resetFields();
  };
  //更换卡商
  function handleChange(value) {
    console.log(`selected ${value}`);
  }
 
  return (
    <div>
      <Tab title="充值信息" />
      <div className={style.content}>
        <Form form={form} name="control-hooks" onFinish={onFinish} labelCol={{ span: 3 }}
          wrapperCol={{ span: 16 }}>
          <Form.Item
            name="num"
            label="转账金额"
            rules={[
              {
                required: true,
                message: '请输入充值金额'
              },
            ]}
          >
            <Input placeholder='单位（元）'/>
          </Form.Item>
          {/* <Form.Item
              label="选择卡商"
              name="cardDealer"
            >
              <Select placeholder="选择卡商" style={{ width: 200 }} onChange={handleChange} >
                {cardDealerArr.map(item=>{
                  return <Option key={item.id} value={item.id}>{item.name}</Option>
                })}
              </Select>
            </Form.Item> */}

          <Form.Item wrapperCol={{
            offset: 3,
            span: 16,
          }}>
            <Button className={style.btn1} type="primary" htmlType="submit">
              确认充值
            </Button> 
            <Button htmlType="button" onClick={onReset} >
              重新填写
            </Button>
          </Form.Item>
        </Form>
      </div>

    </div>
  )
}
